home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic 4 Database How-To
/
Visual Basic 4 Database - How-to (The Waite Group)(1995).iso
/
select1.fr_
/
select1.fr
Wrap
Text File
|
1995-07-04
|
4KB
|
132 lines
VERSION 4.00
Begin VB.Form Form1
BackColor = &H00C0C0C0&
Caption = "Simple SELECTer"
ClientHeight = 4665
ClientLeft = 225
ClientTop = 1815
ClientWidth = 7575
Height = 5070
Left = 165
LinkTopic = "Form1"
ScaleHeight = 4665
ScaleWidth = 7575
Top = 1470
Width = 7695
Begin VB.CommandButton cmdClose
Caption = "Close"
Default = -1 'True
BeginProperty Font
name = "MS Sans Serif"
charset = 0
weight = 700
size = 8.25
underline = 0 'False
italic = 0 'False
strikethrough = 0 'False
EndProperty
Height = 555
Left = 3120
TabIndex = 2
Top = 3780
Width = 1335
End
Begin VB.ListBox lstTitles
Height = 1035
Left = 480
TabIndex = 1
Top = 2160
Width = 6555
End
Begin VB.Data Data1
Caption = "Data1"
Connect = "Access"
DatabaseName = "C:\VB\BIBLIO.MDB"
Exclusive = 0 'False
Height = 300
Left = 480
Options = 0
ReadOnly = 0 'False
RecordsetType = 2 'Snapshot
RecordSource = "SELECT [Company Name] FROM [Publishers] WHERE STATE = 'NY' ORDER BY [Company Name]"
Top = 1800
Visible = 0 'False
Width = 2115
End
Begin MSDBCtls.DBList dblPublishers
Bindings = "SELECT1.frx":0000
Height = 1035
Left = 480
TabIndex = 0
Top = 360
Width = 5175
_Version = 65536
_ExtentX = 9128
_ExtentY = 1826
_StockProps = 77
BackColor = -2147483643
MatchEntry = 1
ListField = "Company Name"
BoundColumn = "Name"
MouseIcon = "SELECT1.frx":000E
End
End
Attribute VB_Name = "Form1"
Attribute VB_Creatable = False
Attribute VB_Exposed = False
Option Explicit
' Change the following to point to your copy of BIBLIO.MDB.
Private Sub Form_Load()
Dim db As DATABASE
Dim dbName As String
Dim rs As Recordset
Dim sql As String
' Set up the error handler.
On Error GoTo FormLoadError
' Get the database name and open the database.
dbName = BiblioPath() ' BiblioPath is a function in READINI.BAS
Set db = DBEngine.Workspaces(0).OpenDatabase(dbName)
' Open a snapshot-type recordset on the [Titles] Table, selecting only
' those titles published in 1993 or 1994. Sort the records by the ISBN
' number.
sql = "SELECT [Title],[ISBN] FROM [Titles]"
sql = sql & " WHERE [Year Published] = 1993 OR [Year Published] = 1994"
sql = sql & " ORDER BY [ISBN]"
Set rs = db.OpenRecordset(sql, dbOpenSnapshot)
' If there is at least one record in the recordset, move through the
' recordset a record at a time until the end of the file (EOF) is
' reached. Display each record in the unbound list box lstTitles.
If rs.RecordCount > 0 Then
rs.MoveFirst
Do While Not rs.EOF
lstTitles.AddItem rs![ISBN] & ": " & rs![Title]
rs.MoveNext
Loop
End If
Exit Sub
FormLoadError:
' Just display Visual Basic's default error message.
MsgBox Error(Err)
Exit Sub
End Sub
Private Sub cmdClose_Click()
End
End Sub